
export default function ajax({option}={}){
    if(!options.type) {
        options.type = 'GET'
    }
    options.url = 'http://localhost:3000' + options.url;
    return new Promise((resolve) =>{
        $.ajax({

            ...option,
            headers: {
                Authorization: localStorage.token
            },
            success(res){
                resolve(res)
            },
            error(err){
                if(err.status == 401){
                    console.log('zzzz');
                    alert('你还未登录，请先登录');
                    location.href = '../login.html';
                }
            }
        })
    })
}